Hi,
I'm trying to save the last date and time a script is executed for a module in a module attribute.
My idea to do that was:
m."Last_Script_Run" = dateAndTime(today()) ""
Though this does only save the current date and not the current time in the attribute "Last_Script_Run". Can anyone here tell me how I can convince DOORS to remember the time also?
Or do I have to store date and time as a string?
Thanks in advance
Michael
MichaelGeorg - Thu Oct 27 10:47:16 EDT 2011 |
|
Re: Store current dateAndTime in module attribute OurGuest - Thu Oct 27 12:46:42 EDT 2011
If you make "Last_Script_Run" type as text or string, your script should work fine.
|
|
Re: Store current dateAndTime in module attribute llandale - Thu Oct 27 14:56:44 EDT 2011
These all print the same value. I wonder if you are retrieving it incorrectly.
Module mod = current
mod."dD" = dateAndTime(today()) // "dD" is type "Date"
mod."dS" = dateAndTime(today()) "" // "dS" is type "string"
mod."dI" = intOf(dateAndTime(today())) // "dI" is type "int"
Date d = mod."dD"
string s = mod."dS"
int i = mod."dI"
print d "\t" s "\t" dateOf(i) "\n"
|
|
Re: Store current dateAndTime in module attribute MichaelGeorg - Fri Oct 28 04:19:11 EDT 2011 llandale - Thu Oct 27 14:56:44 EDT 2011
These all print the same value. I wonder if you are retrieving it incorrectly.
Module mod = current
mod."dD" = dateAndTime(today()) // "dD" is type "Date"
mod."dS" = dateAndTime(today()) "" // "dS" is type "string"
mod."dI" = intOf(dateAndTime(today())) // "dI" is type "int"
Date d = mod."dD"
string s = mod."dS"
int i = mod."dI"
print d "\t" s "\t" dateOf(i) "\n"
@OurGuest: Yes, if I use text instead of date the script works fine. I've already tested that. However I don't like to store a date in something else like a date.
I know it's hard with DXL but I still try to stick to some programming paradigms :-)
@Ilandale:
Now it gets really interesting. Executing your code indeed printed the same value three times.
So I started playing a little bit around and recognized the phenomenon that once you have assigned a date without a time to a date attribute you can not later assign date and time to that attribute.
I've created two date Attributes testDateAttr1 and testDateAttr2 set the value for testDateAttr2 manually to a date without a time and then executed the following script:
Module m = current
//testDateAttr1 and testDateAttr2 are of type "Date"
m."testDateAttr1" = dateAndTime(today())
m."testDateAttr2" = dateAndTime(today())
Date testDate1 = m."testDateAttr1"
Date testDate2 = m."testDateAttr2"
print testDate1 "\t" testDate2 ""
Which generated the following result in my DXL Output:
10/28/11 10:15:06 28 October 2011
|
|
Re: Store current dateAndTime in module attribute Tony_Goodman - Fri Oct 28 09:31:19 EDT 2011 MichaelGeorg - Fri Oct 28 04:19:11 EDT 2011
@OurGuest: Yes, if I use text instead of date the script works fine. I've already tested that. However I don't like to store a date in something else like a date.
I know it's hard with DXL but I still try to stick to some programming paradigms :-)
@Ilandale:
Now it gets really interesting. Executing your code indeed printed the same value three times.
So I started playing a little bit around and recognized the phenomenon that once you have assigned a date without a time to a date attribute you can not later assign date and time to that attribute.
I've created two date Attributes testDateAttr1 and testDateAttr2 set the value for testDateAttr2 manually to a date without a time and then executed the following script:
Module m = current
//testDateAttr1 and testDateAttr2 are of type "Date"
m."testDateAttr1" = dateAndTime(today())
m."testDateAttr2" = dateAndTime(today())
Date testDate1 = m."testDateAttr1"
Date testDate2 = m."testDateAttr2"
print testDate1 "\t" testDate2 ""
Which generated the following result in my DXL Output:
10/28/11 10:15:06 28 October 2011
Running that code, I am able to change the date-only value to a date-time value.
But, I notice in the GUI that if I have a date attribute set with a date-time value and I try to change it to the same date without time, it refuses to change and retains the time.
The opposite is also true.
Changing to a different date works fine.
Curious.
Tony Goodman, www.smartdxl.com
|
|
Re: Store current dateAndTime in module attribute Tony_Goodman - Fri Oct 28 09:35:56 EDT 2011 Tony_Goodman - Fri Oct 28 09:31:19 EDT 2011
Running that code, I am able to change the date-only value to a date-time value.
But, I notice in the GUI that if I have a date attribute set with a date-time value and I try to change it to the same date without time, it refuses to change and retains the time.
The opposite is also true.
Changing to a different date works fine.
Curious.
Tony Goodman, www.smartdxl.com
Sorry, forgot to mention the above is referring to setting dates on an object level attribute directly in a column, not using properties dialog.
Module attributes seem to work as expected. I am using 9.2.
Tony Goodman, www.smartdxl.com
|
|
Re: Store current dateAndTime in module attribute llandale - Fri Oct 28 11:09:14 EDT 2011 MichaelGeorg - Fri Oct 28 04:19:11 EDT 2011
@OurGuest: Yes, if I use text instead of date the script works fine. I've already tested that. However I don't like to store a date in something else like a date.
I know it's hard with DXL but I still try to stick to some programming paradigms :-)
@Ilandale:
Now it gets really interesting. Executing your code indeed printed the same value three times.
So I started playing a little bit around and recognized the phenomenon that once you have assigned a date without a time to a date attribute you can not later assign date and time to that attribute.
I've created two date Attributes testDateAttr1 and testDateAttr2 set the value for testDateAttr2 manually to a date without a time and then executed the following script:
Module m = current
//testDateAttr1 and testDateAttr2 are of type "Date"
m."testDateAttr1" = dateAndTime(today())
m."testDateAttr2" = dateAndTime(today())
Date testDate1 = m."testDateAttr1"
Date testDate2 = m."testDateAttr2"
print testDate1 "\t" testDate2 ""
Which generated the following result in my DXL Output:
10/28/11 10:15:06 28 October 2011
I agree with your paradigm comment striving to keep things theoretically pure; but I also believe that the relative importance of things drop far faster in practice then in theory and therefore there are times you "should" do the simple practical thing rather than the complicated theoretical thing. For example is far more important to completely comment up the flow of you program's main function then it is to completely comment up one of the trivial functions; yet "theory" says they are equally important.
In this case perhaps OurGuest is right, make it a string attribute and move on.
But that's for lesser folks than you and I!
I did exactly what you said and do not get your results in v9304. A new attr value initially set to the long date indeed updates to date and time as expected. What version of DOORS are you using? Please don't be offended, but let's check these trivial errors:
<1> You did spell the attributes correctly?
<2> You didn't create your own 'Date' attr type and play with it?
<3> You did not accidentally mark this attr as an AttrDXL?
<4> There is not tricky AttrDXL going on at all?
<5> The module properties sheet isn't still open?
Where "far lesser folks" means "folks with far less ADHD OCD".
|
|
Re: Store current dateAndTime in module attribute MichaelGeorg - Mon Nov 07 08:10:18 EST 2011 llandale - Fri Oct 28 11:09:14 EDT 2011
I agree with your paradigm comment striving to keep things theoretically pure; but I also believe that the relative importance of things drop far faster in practice then in theory and therefore there are times you "should" do the simple practical thing rather than the complicated theoretical thing. For example is far more important to completely comment up the flow of you program's main function then it is to completely comment up one of the trivial functions; yet "theory" says they are equally important.
In this case perhaps OurGuest is right, make it a string attribute and move on.
But that's for lesser folks than you and I!
I did exactly what you said and do not get your results in v9304. A new attr value initially set to the long date indeed updates to date and time as expected. What version of DOORS are you using? Please don't be offended, but let's check these trivial errors:
<1> You did spell the attributes correctly?
<2> You didn't create your own 'Date' attr type and play with it?
<3> You did not accidentally mark this attr as an AttrDXL?
<4> There is not tricky AttrDXL going on at all?
<5> The module properties sheet isn't still open?
Where "far lesser folks" means "folks with far less ADHD OCD".
When I posted my quested we were still using DOORS 8.3. In the meantime we have switched to DOORS 9.3 and with that new version I can't reproduce the behaviour I described above.
So this is a fixed bug and nothing to worry about any more.
Thanks for your feedback and help!
Michael
|
|